package com.application.examples.entity;

/**
 * @author xiongwei_vendor
 * @date 2020/11/25 19:08
 */
public class BaseException extends RuntimeException  {

    private static final long serialVersionUID = 1L;
    private String code;
    private String msg;

    public BaseException(ResultCode resultCode) {
        super(resultCode.getMsg());
        this.code = resultCode.getCode();
        this.msg = String.format(resultCode.getMsg(), "");
    }

    public BaseException(ResultCode resultCode, String message) {
        super(resultCode.getMsg());
        this.code = resultCode.getCode();
        this.msg = String.format(resultCode.getMsg(), message);
    }

    public BaseException(ResultCode resultCode, Throwable throwable) {
        super(throwable);
        this.code = resultCode.getCode();
        this.msg = String.format(resultCode.getMsg(), "");
    }

    public BaseException(ResultCode resultCode, String message, Throwable throwable) {
        super(throwable);
        this.code = resultCode.getCode();
        this.msg = String.format(resultCode.getMsg(), message);
    }

    public BaseException(String code, String message, Throwable throwable) {
        super(throwable);
        this.code = code;
        this.msg = message;
    }

    public BaseException(String code, String message) {
        super(message);
        this.code = code;
        this.msg = message;
    }

    public String toString() {
        return "BaseException{code='" + this.code + '\'' + ", msg='" + this.msg + '\'' + '}';
    }

    public String getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    public void setMsg(final String msg) {
        this.msg = msg;
    }

}
